var prefix = ctx + "manage/configuration";


/*常规配置-新增*/
function add() {
    var url = prefix + '/add';
    layer_showAuto("新增常规配置", url);
}

// 当前长度 122
var key = ["app_id", "banner", "incentive_video_callback", "time_interval", "ad_gm_secret_key",
    "incentive_video", "spread_its_tail", "ad_insert_half_screen", "ad_information_flow", "allocation_ad", "allocation_money_gold_coin",
    "allocation_money_red_packet", "daily_task_frequency", "withdrawal_number", "zfb_url", "zfb_app_id",
    "zfb_secret_key", "zfb_app_cert_path", "zfb_alipay_public_cert_path", "zfb_root_cert_path", "sign_in_one",
    "sign_in_two", "sign_in_three", "sign_in_four", "sign_in_five", "sign_in_six", "sign_in_seven", "sign_in_eight",
    "download_link", "mail_smtp_host", "mail_smtp_username", "mail_smtp_password", "mail_from",
    "your_mail", "ad_ecpm", "app_spread_its_tail", "app_banner", "app_answer_incentive", "app_full_screen",
    "app_flow_answer_incorrectly", "app_flow_answer", "app_flow_reward", "app_table_plaque_withdrawal", "app_flow_my",
    "app_table_plaque_record", "app_answer_sign_in", "app_answer_withdrawal", "ad_insert_full_screen", "app_flow_withdrawal",
    "proxy_promotion_commission", "playlet_free_set", "withdrawal_number_sign", "risk_developer_mode_app", "location_awkj_public_key",
    "risk_developer_mode_backstage", "risk_debug_mode_app", "risk_debug_mode_backstage", "risk_root_app", "risk_root_backstage",
    "risk_accessibility_app", "risk_accessibility_backstage", "risk_id_proxy_app", "risk_id_proxy_backstage", "app_name", "app_qq_communication_group",
    "app_qq_customer_service", "risk_ip_login_number", "risk_advertising_coins", "risk_white_list", "risk_advertising_coins_than_equal", "risk_double_open_app",
    "risk_double_open_backstage", "risk_simulator_app", "risk_simulator_backstage", "risk_advertising_coins_than_equal_two", "ta_ku", "gro_more", "ta_ku_app_id",
    "ta_ku_app_key", "ta_ku_banner", "ta_ku_incentive_video_callback", "ta_ku_ad_gm_secret_key", "ta_ku_incentive_video", "ta_ku_spread_its_tail",
    "ta_ku_ad_insert_half_screen", "ta_ku_ad_insert_full_screen", "ta_ku_ad_information_flow", "gm_video", "gm_short_play", "time_interval_answer",
    "time_interval_answer_error", "time_interval_answer_receive", "bind_zfb", "risk_single_clear", "risk_shuang_qing", "wx_login_app_id", "wx_login_app_secret",
    "risk_ip_same_network", "risk_app_black_list", "app_banner_1", "app_banner_2", "app_banner_3", "app_banner_4", "app_banner_5", "app_banner_6", "app_banner_7",
    "app_banner_8", "app_banner_9", "app_answer_3", "app_flow_4", "app_flow_5", "app_table_plaque_0", "app_table_plaque_1", "app_table_plaque_2", "app_table_plaque_3",
    "app_table_plaque_4", "app_table_plaque_5", "app_table_plaque_6", "app_table_plaque_7", "app_table_plaque_10", "app_table_plaque_11", "app_home", "app_classification",
    "file_storage_address", "file_download_address", "bidding_deputy_guang","withdrawal_white_list", "sign_in_nine"
];

/*常规配置-修改*/
function editConfig(index) {
    var input = $("#index" + index);
    input.prop('disabled', function (i, disabled) {
        return !disabled;
    });
    var isDisabled = input.prop('disabled');
    if (isDisabled) {
        //发送请求
        $("#but" + index).html("编辑");
        var keyData = key[index] + uvChannel;
        if(index=== 63 || index === 123 || index === 124){
            keyData = key[index];
        }
        _ajax_query(ctx + "manage/configuration/save", {key: keyData, value: input.val()}, function (result) {
            if (result.code == web_status.SUCCESS) {
                $.modalMsg(result.msg, modal_status.SUCCESS);
            } else {
                $.modalAlert(result.msg, modal_status.FAIL);
            }
        });
    } else {
        $("#but" + index).html("保存");
    }
}

function checkStatus(index) {
    var input = $("#index" + index);
    var checkStatus = $("#status" + index);
    if (checkStatus.is(":checked")) {
        input.val(1);
    } else {
        input.val(2);
    }
    var keyData = key[index] + uvChannel;
    if(index=== 63 || index === 123 || index === 124){
        keyData = key[index];
    }
    _ajax_query(ctx + "manage/configuration/save", {key: keyData, value: input.val()}, function (result) {
        if (result.code == web_status.SUCCESS) {
            $.modalMsg(result.msg, modal_status.SUCCESS);
        } else {
            $.modalAlert(result.msg, modal_status.FAIL);
        }
    });
}

function update() {
    _ajax_save(ctx + "manage/configuration/save", []);
}

